Skip to content

.NET code patching template + infrastructure#14467

Open
m-redding wants to merge 12 commits intoAzure:mainfrom
m-redding:net-customizations
Open

.NET code patching template + infrastructure#14467
m-redding wants to merge 12 commits intoAzure:mainfrom
m-redding:net-customizations

Conversation

@m-redding
Copy link
Member

@m-redding m-redding commented Mar 11, 2026

Resolves: #14274

Adds the .NET equivalent of the Java/Python error-driven patch template, enabling the customization repair pipeline to fix C# build errors in
partial-class customization files.

What's included

  • DotnetErrorDrivenPatchTemplate — Prompt template grounded in Azure SDK for .NET partial-class patterns (Generated/ folder, .cs
    customizations)
  • DotnetLanguageService.ApplyPatchesAsync — Wires up the patch agent with ReadFile, GrepSearch, CodePatch, and a new RenameFile tool
  • FileTools.CreateRenameFileTool — New tool for renaming customization files when a class is renamed (with path-traversal protection)
  • Logging fix — Suppress Copilot SDK noise even in debug mode

.NET-specific additions over Java/Python

  • Filters out Generated/ folder files from customization file discovery
  • Early-exits when no .cs files exist (avoids unnecessary agent invocation)
  • RenameFile tool for class-rename scenarios (file name must match class name in .NET)
  • Prompt guidance for cascading errors and analyzer rule suppression

Tests

  • DotnetErrorDrivenPatchTemplateTests — Prompt content validation
  • DotnetLanguageServicePatchTests — Agent invocation, error handling, Generated file exclusion, cancellation propagation
  • FileToolsTests (RenameFile) — Success, security (path traversal), edge cases

@github-actions github-actions bot added the azsdk-cli Issues related to Azure/azure-sdk-tools::tools/azsdk-cli label Mar 11, 2026
@m-redding m-redding changed the title wip .net customization work .NET code patching template + infrastructure Mar 16, 2026
@m-redding m-redding marked this pull request as ready for review March 18, 2026 17:13
@m-redding m-redding requested a review from a team as a code owner March 18, 2026 17:13
Copilot AI review requested due to automatic review settings March 18, 2026 17:13
@m-redding m-redding requested a review from benbp March 18, 2026 17:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds .NET support to azsdk-cli’s error-driven customization repair pipeline, aligning with the existing Java/Python patch-agent flow while accounting for .NET partial-class conventions (e.g., Generated/ vs customization files and class/file rename coupling).

Changes:

  • Introduces DotnetErrorDrivenPatchTemplate to guide an agent to apply safe, surgical fixes to C# customization files based on build errors.
  • Wires DotnetLanguageService.ApplyPatchesAsync to run the patch agent with ReadFile, GrepSearch, CodePatchTool, and a new RenameFile tool (with generated-code exclusion and early exit when no .cs files exist).
  • Adds FileTools.CreateRenameFileTool (path-traversal protected) plus tests; also adjusts logging to always suppress Copilot SDK noise even in debug mode.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tools/azsdk-cli/Azure.Sdk.Tools.Cli/Services/Languages/DotnetLanguageService.cs Adds patch-agent execution for .NET customization repair, excludes Generated/, includes RenameFile tool.
tools/azsdk-cli/Azure.Sdk.Tools.Cli/Prompts/Templates/DotnetErrorDrivenPatchTemplate.cs New .NET-specific error-driven patch prompt grounded in partial-class patterns and safe patching rules.
tools/azsdk-cli/Azure.Sdk.Tools.Cli/Program.cs Always suppresses GitHub.Copilot.SDK logs below warning level, even in debug mode.
tools/azsdk-cli/Azure.Sdk.Tools.Cli/CopilotAgents/Tools/FileTools.cs Adds RenameFile AIFunction with safe path resolution and basic rename validations.
tools/azsdk-cli/Azure.Sdk.Tools.Cli.Tests/Tools/Package/SdkBuildToolTests.cs Updates DotnetLanguageService construction for new ICopilotAgentRunner dependency.
tools/azsdk-cli/Azure.Sdk.Tools.Cli.Tests/Tools/Package/PackToolTests.cs Updates DotnetLanguageService construction for new ICopilotAgentRunner dependency.
tools/azsdk-cli/Azure.Sdk.Tools.Cli.Tests/Tools/Generators/SampleGeneratorToolTests.cs Updates DotnetLanguageService construction for new ICopilotAgentRunner dependency.
tools/azsdk-cli/Azure.Sdk.Tools.Cli.Tests/Services/Languages/LanguageServicePackageInfoTests.cs Updates DotnetLanguageService construction for new ICopilotAgentRunner dependency.
tools/azsdk-cli/Azure.Sdk.Tools.Cli.Tests/Services/Languages/DotnetLanguageServicePatchTests.cs New tests validating .NET patch agent invocation behavior, exclusions, and cancellation propagation.
tools/azsdk-cli/Azure.Sdk.Tools.Cli.Tests/Services/Languages/DotNetLanguageSpecificChecksTests.cs Updates DotnetLanguageService construction for new ICopilotAgentRunner dependency.
tools/azsdk-cli/Azure.Sdk.Tools.Cli.Tests/Prompts/Templates/DotnetErrorDrivenPatchTemplateTests.cs New tests validating prompt content and expected guidance/tool references.
tools/azsdk-cli/Azure.Sdk.Tools.Cli.Tests/Helpers/DotNetPackageInfoHelperTests.cs Updates DotnetLanguageService construction for new ICopilotAgentRunner dependency.
tools/azsdk-cli/Azure.Sdk.Tools.Cli.Tests/CopilotAgents/Tools/FileToolsTests.cs Adds RenameFile tool tests (success, traversal protection, edge cases, callback, directory creation).

@samvaity samvaity added the Scenario 2 Used for tracking work related to the Dev Inner Loop group's Scenario 2 spec. label Mar 18, 2026
@m-redding m-redding requested a review from samvaity March 18, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azsdk-cli Issues related to Azure/azure-sdk-tools::tools/azsdk-cli Scenario 2 Used for tracking work related to the Dev Inner Loop group's Scenario 2 spec.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add csharp template for patching code customizations

4 participants